package auth

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	v1 "gitee.com/liuxuezhan/ar-platform/rpc-client/authRoleClient/api/role/v1"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetPermissionFunctionIdsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 获取权限功能
func NewGetPermissionFunctionIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPermissionFunctionIdsLogic {
	return &GetPermissionFunctionIdsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetPermissionFunctionIdsLogic) GetPermissionFunctionIds(req *types.GetPermissionFunctionIdsRequest) (resp *types.GetPermissionFunctionIdsResponse, err error) {
	reply, err := l.svcCtx.AuthRoleRpc.GetPermissionFunctionIds(l.ctx, &v1.GetPermissionFunctionIdsRequest{PermissionId: req.PermissionId})
	if err != nil {
		return nil, err
	}
	return &types.GetPermissionFunctionIdsResponse{FunctionIds: reply.GetFunctionIds()}, err
}
